<?php
	if (!isset($_GET['search'])) {
		$dataProvider = $model->searchAdvance();
		$model = $dataProvider->getData();
		$page = new CPagination();
		$page->setItemCount(Job::model()->count($dataProvider->criteria));
		$page->setPageSize(15);
		$page->applyLimit($dataProvider->criteria);
	}
?>
<div id="content">
	<div id="main_content" class="fixed clear">
	
		<span class="job_title"><?php //echo $list->name;?></span>
		<a href="index.php?r=job/create" class="is_button">Tạo việc làm
		</a>
		<div class="fb-like" data-href="http://localhost/freelancer/" data-send="true" data-width="450" data-show-faces="true" data-font="lucida grande"></div>
					<div id="fb-root"></div>
					<script>(function(d, s, id) {
					  var js, fjs = d.getElementsByTagName(s)[0];
					  if (d.getElementById(id)) return;
					  js = d.createElement(s); js.id = id;
					  js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1";
					  fjs.parentNode.insertBefore(js, fjs);
					}(document, 'script', 'facebook-jssdk'));
					</script>			
		<p class="alt"></p>
		<p class="clear"></p>
	
		<h1><?php //echo $model->subjobtype_id;?></h1>
		<?php $this->widget('application.components.Job.SearchAdvanceJob'); ?><hr />
		<span class="col_title">Result Works</span>
		<table class="job_list" width="100%">
            <thead>
                <th width="30%">Tên dự án</th>
                <th width="15%">Ngành</th>
                <th width="5%">Bid(s)</th>
                <th width="20%">Khoảng tiền</th>
                <th width="20%">Yêu cầu</th>
                <th width="5%">Start</th>
                <th width="5%">End</th>
            </thead>
            <tbody>
			<?php 
				foreach ($model as $key):
						$countBid = Bidjob::model()->countByAttributes(array('job_id'=>$key->id));
			?> 
                <tr>
                    <td><?php echo CHtml::link(substr($key->name, 0, 50), array('job/view', 'id'=>$key->id)); ?></td>
                    <td>
						<?php					
							$jobtype = new Job();
							echo $jobtype->getJob($key->subjobtype_id);					
						?>
					</td>
                    <td><?php echo $countBid; ?></td>

                    <td><?php echo $key->budget->money;?></td>
					
                    <td><?php echo $key->skillsrequired;?></td>
                    <td>Today</td>
                    <td>5days</td>
                </tr>
			<?php endforeach; ?>
            </tbody>
			<?php $this->widget("CLinkPager", array('pages'=>$page));?>
        </table>
		<?php //if(!isset($_GET['search'])) 
			//$this->widget("CLinkPager", array('pages'=>$page));
		?>
	</div>
</div>